from leonardo.atom import Feed
from leonardo.cms.models import Page
from leonardo.cms.views import format

class FullFeed(Feed):
    feed_id = "http://jtauber.com/atom/full"
    feed_title = "James Tauber's Blog"
    feed_authors = [{"name": "James Tauber"}]
    feed_links = [
        {"rel": "self", "href": "http://jtauber.com/atom/full"}, # @@@
        {"rel": "alternate", "href": "http://jtauber.com/blog/"}, # @@@
    ]
    
    def items(self):
        return Page.objects.filter(path__startswith="blog/").order_by('-creation_time')[:20]
    
    def item_id(self, item):
        return "http://jtauber.com/" + item.path # @@@
    
    def item_links(self, item):
        return [
            {"rel": "alternate", "href": item.get_absolute_url()}, # @@@
        ]
    
    def item_title(self, item):
        return item.page_title
    
    def item_updated(self, item):
        return item.last_modified
    
    def item_content(self, item):
        return {"type": "html"}, format(item, None)
    
    def item_published(self, item):
        return item.creation_time
